import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:toatool/src/theme/app_theme.dart';

class MitListTile extends StatelessWidget {
  final String? iconPath;
  final String titleText;
  final String? trailingText;
  final bool trailingImportant;
  final VoidCallback callback;

  MitListTile({
    this.iconPath,
    required this.titleText,
    this.trailingText,
    this.trailingImportant = false,
    required this.callback,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: callback,
      child: Container(
        padding: EdgeInsets.symmetric(
          horizontal: ScreenUtil().setWidth(16),
          vertical: ScreenUtil().setHeight(16),
        ),
        child: Flex(
          direction: Axis.horizontal,
          verticalDirection: VerticalDirection.down,
          children: [
            Expanded(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  if (iconPath != null)
                    Image.asset(
                      iconPath!,
                      height: ScreenUtil().setHeight(22),
                    ),
                  if (iconPath != null)
                    SizedBox(
                      width: ScreenUtil().setHeight(20),
                    ),
                  Text(
                    titleText,
                    style: Theme.of(context).textTheme.bodyText2!.copyWith(
                          height: 1.5,
                          fontSize: ScreenUtil().setSp(16),
                          color: darkBlackTextColor,
                        ),
                  )
                ],
              ),
            ),
            Expanded(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  if (trailingText != null)
                    Text(
                      trailingText!,
                      style: Theme.of(context).textTheme.bodyText2!.copyWith(
                            height: 1.5,
                            color: trailingImportant == true
                                ? mitColor
                                : greyTextColor,
                          ),
                    ),
                  Image.asset(
                    'assets/icons/keyboard_arrow_right.png',
                    width: ScreenUtil().setHeight(20),
                    height: ScreenUtil().setHeight(20),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
